Ext.namespace('Divo');
Ext.namespace('Divo.app');

Divo.app.StockInRightForm = Ext.extend(Divo.Base.EditForm, {
      fields : new Ext.util.MixedCollection(),
      dataRecordMeta : Ext.data.Record.create([{
            name : "_p_record_status",
            type : "string"
          }, {
            name : "id",
            type : "float"
          }, {
            name : "consumId",
            type : "float"
          }, {
            name : "stackId",
            type : "float"
          }, {
            name : "consumName",
            type : "string"
          }, {
            name : "spec",
            type : "string"
          }, {
            name : "unit",
            type : "string"
          }, {
            name : "listId",
            type : "float"
          }, {
            name : "packaging",
            type : "string"
          }, {
            name : "pre",
            type : "string"
          }, {
            name : "price",
            type : "float"
          }, {
            name : "lastPrice",
            type : "float"
          }, {
            name : "stackName",
            type : "string"
          }, {
            name : "producer",
            type : "string"
          }, {
            name : "amount",
            type : "float"
          }, {
            name : "nowPrice",
            type : "float"
          }, {
            name : "nowInPrice",
            type : "float"
          }, {
            name : "nowMoney",
            type : "float"
          }, {
            name : "nowInMoney",
            type : "float"
          }]),
      initComponent : function() {
        var me = this;
        var tn = 1;

        this.fields.add("_p_record_status", new Ext.form.Hidden({
                  name : "_p_record_status"
                }));
        this.fields.add("id", new Ext.form.Hidden({
                  name : "id",
                  dataIndex : "id",
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("consumId", new Ext.form.Hidden({
                  name : "consumId",
                  dataIndex : "consumId",
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("stackId", new Ext.form.Hidden({
                  name : "stackId",
                  dataIndex : "stackId",
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("listId", new Ext.form.Hidden({
                  name : "listId",
                  dataIndex : "listId",
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("consumName", new app.base.ComboBox({
                  fieldLabel : '消耗品名称',
                  name : 'consumName',
                  tabIndex : tn++,
                  store : Divo.com.Lib.getStockDs(),
                  displayField : 'name',
                  dataIndex : 'consumName',
                  mode : 'remote',
                  typeAhead : false,
                  forceSelection : true,
                  loadingText : '正在搜索...',
                  listWidth : 300,
                  labelSeparator : ":*",
                  width : 100,
                  minChars : 0,
                  allowBlank : false,
                  tpl : Divo.com.Lib.getStockDs(),
                  insert_allowed : true,
                  update_allowed : true,
                  onSelect : function(record) {
                    var data = record.data;
                    me.setFieldValue("consumName", data.name);
                    me.setFieldValue("consumId", data.id);
                    this.onTriggerClick();
                  }
                }));
        this.fields.add("spec", new app.base.TextField({
                  name : "spec",
                  dataIndex : "spec",
                  fieldLabel : "规格",
                  allowBlank : false,
                  labelSeparator : ":*",
                  width : 100,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("unit", new app.base.TextField({
                  name : "unit",
                  dataIndex : "unit",
                  fieldLabel : "基本单位",
                  allowBlank : true,
                  width : 100,
                  insert_allowed : false,
                  update_allowed : false
                }));
        this.fields.add("packaging", new app.base.TextField({
                  name : "packaging",
                  dataIndex : "packaging",
                  fieldLabel : "包装单位",
                  allowBlank : true,
                  width : 100,
                  insert_allowed : false,
                  update_allowed : false
                }));
        this.fields.add("price", new app.base.TextField({
                  name : "price",
                  dataIndex : "price",
                  fieldLabel : "零价",
                  allowBlank : true,
                  width : 100,
                  insert_allowed : false,
                  update_allowed : false
                }));
        this.fields.add("pre", new app.base.TextField({
                  name : "pre",
                  dataIndex : "pre",
                  fieldLabel : "换算因子",
                  allowBlank : true,
                  width : 100,
                  insert_allowed : false,
                  update_allowed : false
                }));
        this.fields.add("lastPrice", new app.base.TextField({
                  name : "lastPrice",
                  dataIndex : "lastPrice",
                  fieldLabel : "进价",
                  allowBlank : true,
                  width : 100,
                  insert_allowed : false,
                  update_allowed : false
                }));
        this.fields.add("stackName", new app.base.TextField({
                  name : "stackName",
                  dataIndex : "stackName",
                  fieldLabel : "货位",
                  allowBlank : true,
                  width : 100,
                  insert_allowed : false,
                  update_allowed : false
                }));
        this.fields.add("producer", new app.base.TextField({
                  name : "producer",
                  dataIndex : "producer",
                  fieldLabel : "生产厂家",
                  allowBlank : true,
                  width : 100,
                  insert_allowed : false,
                  update_allowed : false
                }));
        this.fields.add("amount", new app.base.TextField({
                  name : "amount",
                  dataIndex : "amount",
                  fieldLabel : "入库数量",
                  allowBlank : false,
                  labelSeparator : ":*",
                  width : 100,
                  insert_allowed : false,
                  update_allowed : false
                }));
        this.fields.add("nowPrice", new app.base.TextField({
                  name : "nowPrice",
                  dataIndex : "nowPrice",
                  fieldLabel : "现零价",
                  allowBlank : true,
                  width : 100,
                  insert_allowed : false,
                  update_allowed : false
                }));
        this.fields.add("nowInPrice", new app.base.TextField({
                  name : "nowInPrice",
                  dataIndex : "nowInPrice",
                  fieldLabel : "零价金额",
                  allowBlank : true,
                  width : 100,
                  insert_allowed : false,
                  update_allowed : false
                }));
        this.fields.add("nowMoney", new app.base.TextField({
                  name : "nowMoney",
                  dataIndex : "nowMoney",
                  fieldLabel : "现进价",
                  allowBlank : false,
                  labelSeparator : ":*",
                  width : 100,
                  insert_allowed : false,
                  update_allowed : false
                }));
        this.fields.add("nowInMoney", new app.base.TextField({
                  name : "nowInMoney",
                  dataIndex : "nowInMoney",
                  fieldLabel : "进价金额",
                  allowBlank : false,
                  labelSeparator : ":*",
                  width : 100,
                  insert_allowed : false,
                  update_allowed : false
                }));
        Ext.apply(this, {
              items : [this.fields.get("_p_record_status"),
                  this.fields.get("id"), this.fields.get("consumId"),
                  this.fields.get("stackId"), this.fields.get("listId"), {
                    layout : "form",
                    columnWidth : 1,
                    labelAlign : "right",
                    labelWidth : 100,
                    width : 500,
                    items : [{
                      layout : 'fit',
                      region : 'center',
                      border : false,
                      items : [{
                        layout : "column",
                        bodyStyle : 'padding:0 0 ;',
                        border : false,
                        items : [{
                          layout : "form",
                          columnWidth : .5,
                          labelAlign : 100,
                          items : [this.fields.get("consumName"),
                              this.fields.get("spec"),
                              this.fields.get("price"),
                              this.fields.get("lastPrice"),
                              this.fields.get("producer"),
                              this.fields.get("amount"),
                              this.fields.get("nowPrice")]
                        }, {
                          layout : "form",
                          columnWidth : .5,
                          labelAlign : 100,
                          items : [this.fields.get("unit"),
                              this.fields.get("packaging"),
                              this.fields.get("pre"),
                              this.fields.get("stackName"),
                              this.fields.get("nowInPrice"),
                              this.fields.get("nowInMoney"),
                              this.fields.get("nowMoney")]
                        }]
                      }]
                    }]
                  }],
              border : false,
              frame : true,
              firstFocusFieldName : "stockName"
            });
        Divo.app.StockInRightForm.superclass.initComponent.apply(this,
            arguments);
      },
      onRender : function() {
        Divo.app.StockInRightForm.superclass.onRender.apply(this, arguments);
      },
      newDataRecord : function() {
        return new this.dataRecordMeta({
              _p_record_status : "insert",
              id : "",
              name : "",
              state : ""
            });
      }

    });
Ext.reg("Divo.app.StockInRightForm", Divo.app.StockInRightForm);